/**
 * Created by chenyi on 2017-08-10 08:56:33
 *  email   :  qq228112142@qq.com
 */

/**跳转到添加页面*/
function add(url){
    parent.layer.open({
        type: 2,
        title: '添加',
        shadeClose: false,
        shade: [0.3, '#000'],
        maxmin: true, //开启最大化最小化按钮
        area: ['893px', '600px'],
        content: url
    });
}
/**跳转到修改页面*/
function edit(table_id,url){
    var id=getSelectedRow(table_id,url);
    if(id!=null){
        parent.layer.open({
            type: 2,
            title: '修改',
            shadeClose: false,
            shade: [0.3, '#000'],
            maxmin: true, //开启最大化最小化按钮
            area: ['893px', '600px'],
            content: url+"/"+id
        });
    }
}
/**删除*/
function deleteBatch(table_id,url){
    //获取选中的id
    var ids= getSelectedRows(table_id);
    if(ids!=null){
        confirm("确认删除？",function(){
            $.ajax({
                type: "post",
                url: url,
                contentType: "application/json",
                data: JSON.stringify(ids),
                async: false,
                dataType:"json",
                success: function (R) {
                    if(R.code === 0){
                        alert('操作成功', function () {
                            //查询表单,刷新列表数据
                            $(".search-btn").click();
                        });
                    }else{
                        alert(R.msg);
                    }
                },
                error:function(){
                    alert("系统繁忙");
                }
            });
        });
    }

}
//查看图片
   function showImg(value){
     var index=  parent.layer.open({
           type: 1,
           title: "查看图片",
           shadeClose: false,
           shade: [0.3, '#000'],
           area: ['1000px', '700px'],
           maxmin: true, //开启最大化最小化按钮
           content: '<img style="margin:20px;" src="'+value+'"/>'
       });
       parent.layer.full(index);
   }

/**数据渲染对象*/
var Render = {
    customWEB: function (rowdata, index, value) {
        if(value == "支持"){
            return '<span style="color:green">'+value+'</span>';
        }
        if(value == "不支持"){
            return '<span style="color:red">'+value+'</span>';
        }
        return value;
    },
    customImg: function (rowdata, index, value) {
        var img= '<img style="max-height:30px;max-width:100px;cursor:pointer" src="'+value+'"  onclick="showImg(\''+value+'\')"> ' ;
        return img;

    }
};
